//
//  UICollectionViewCell+TZExtension.m
//  TZOCExtension
//
//  Created by Tim.Z on 2017/1/3.
//  Copyright © 2017年 Tim.Z. All rights reserved.
//

#import "UICollectionViewCell+TZExtension.h"

@interface UICollectionViewCell ()

@property (nonatomic, copy) NSString *theReuseID;

@end

@implementation UICollectionViewCell (TZExtension)

- (NSString *)theReuseID{
    return [NSString stringWithFormat:@"%@ID", NSStringFromClass([self class])];
}

- (__kindof UICollectionViewCell *)tz_cellNibWithCollection:(UICollectionView *)collectionView forIndexPath:(NSIndexPath *)indexPath{
    
    UINib *nib = [UINib nibWithNibName:NSStringFromClass([self class]) bundle:[NSBundle mainBundle]];
    [collectionView registerNib:nib forCellWithReuseIdentifier:self.theReuseID];
    
    __kindof UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:[self theReuseID] forIndexPath:indexPath];
    
    if (collectionView.tz_VC) {
        self.tz_VC = collectionView.tz_VC;
    }
    
    return cell;
}

- (__kindof UICollectionViewCell *)tz_cellClassWithCollection:(UICollectionView *)collectionView forIndexPath:(NSIndexPath *)indexPath{

    [collectionView registerClass:[self class] forCellWithReuseIdentifier:self.theReuseID];
    
    __kindof UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:[self theReuseID] forIndexPath:indexPath];
    
    if (collectionView.tz_VC) {
        self.tz_VC = collectionView.tz_VC;
    }
    
    return cell;
}

@end
